home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / pack / crunchmania / crmpw.s < prev    next >
Text File  |  1980-01-03  |  4KB  |  194 lines

  1. ***********************************
  2. ***   CrMPW V1.0                ***
  3. ***   (c) 1993 Thomas Schwarz   ***
  4. ***********************************
  5.  
  6.     incdir    dh0:ass/Include/
  7.     include    dos/dos_lib.i
  8.     include    exec/exec_lib.i
  9.     include    utility/tagitem.i
  10.     include    libraries/CrM.i
  11.     include    libraries/CrM_lib.i
  12.  
  13. ***************************************
  14. CALL    MACRO
  15.     jsr    _LVO\1(a6)
  16.     ENDM
  17. CALLEXEC MACRO
  18.     move.l    4.w,a6
  19.     CALL    \1
  20.     ENDM
  21. CALLDOS    MACRO
  22.     move.l    _DOSBase(pc),a6
  23.     CALL    \1
  24.     ENDM
  25. ***************************************
  26. main:
  27.     lea    CLIParas(pc),a1
  28.     movem.l    d0/a0,(a1)        ;save CLI-Parameters
  29.  
  30. ** Open dos.library: **
  31.     lea    DOSName(pc),a1
  32.     CALLEXEC OldOpenLibrary
  33.     lea    _DOSBase(pc),a0
  34.     move.l    d0,(a0)
  35.     beq.w    .End
  36.  
  37. ** Get Output Handle for the CLI: **
  38.     move.l    d0,a6
  39.     CALL    Output
  40.     lea    OutHandle(pc),a0
  41.     move.l    d0,(a0)
  42.     beq.w    .CloseDOS
  43.  
  44. ** Open CrM.library: **
  45.     lea    CrMName(pc),a1
  46.     moveq    #4,d0
  47.     CALLEXEC OpenLibrary
  48.     lea    _CrMBase(pc),a0
  49.     move.l    d0,(a0)
  50.     beq.w    .nocrm
  51.  
  52.     lea    InitTxt(pc),a0
  53.     bsr.w    PrintText
  54.  
  55.     movem.l    CLIParas(pc),d0/a0
  56.     tst.l    d0
  57.     beq.w    .printinfo
  58.     clr.b    -1(a0,d0.w)    ;replace <cr> with 0
  59.     bsr.w    SkipSpaces
  60.     move.b    (a0),d1
  61.     beq.w    .printinfo    ;no parameters
  62.     bclr    #5,d1        ;upcase
  63.     cmp.b    #"A",d1
  64.     beq.s    .checkadd    ;check for following <Space>
  65.     cmp.b    #"R",d1
  66.     beq.s    .checkremove    ;check for following <Space>
  67. .switch:
  68.     moveq    #0,d0
  69. .checkcont:
  70. ;    lea    PW(pc),a1
  71. ;    move.l    a0,(a1)        ;store address of pw
  72.     tst.b    (a0)
  73.     beq.w    .nopw        ;TextEnd!
  74.     move.l    d0,d7
  75.     move.l    _CrMBase(pc),a6
  76.     CALL    cmProcessPW
  77.     tst.l    d7
  78.     beq.w    .success    ;Operation=Switch -> always successfull
  79.     cmp.w    d0,d7
  80.     beq.w    .success    ;function did what i wanted!
  81.     lea    NoAddTxt(pc),a0
  82.     cmp.w    #cm_AddPW,d7
  83.     beq.s    .schluss
  84.     lea    NoRemTxt(pc),a0
  85. ;    cmp.w    #cm_RemovePW,d7            ;in the present version
  86. ;    beq.s    .schluss            ;of the library this case
  87. ;    lea    NoRemAllTxt(pc),a0        ;can never occur!
  88. .schluss:
  89.     bsr.w    PrintText    ;print result...
  90.  
  91. ** Close CrM.library **
  92.     move.l    _CrMBase(pc),d0
  93.     beq.s    .CloseDOS
  94.     move.l    d0,a1
  95.     CALLEXEC CloseLibrary
  96.  
  97. ** Close dos.library **
  98. .CloseDOS:
  99.     move.l    _DOSBase(pc),a1
  100.     CALLEXEC CloseLibrary
  101. .End:    moveq    #0,d0
  102.     rts
  103. *-------
  104. .checkadd:
  105.     cmp.b    #" ",1(a0)
  106.     bne.s    .switch            ;no <Space>
  107.     moveq    #cm_AddPW,d0
  108.     addq.l    #1,a0
  109.     bsr.w    SkipSpaces
  110.     bra.s    .checkcont
  111. *-------
  112. .checkremove:
  113.     cmp.b    #" ",1(a0)
  114.     bne.s    .switch            ;no <Space>
  115.     moveq    #cm_RemovePW,d0
  116.     addq.l    #1,a0
  117.     bsr.s    SkipSpaces
  118.     cmp.b    #"a",(a0)
  119.     bne.s    .checkcont
  120.     cmp.b    #"l",1(a0)
  121.     bne.w    .checkcont
  122.     cmp.b    #"l",2(a0)
  123.     bne.w    .checkcont
  124.     tst.b    3(a0)
  125.     bne.w    .checkcont
  126.     moveq    #cm_RemoveAll,d0
  127.     bra.w    .checkcont
  128. *-------
  129. .success:
  130.     lea    AddedTxt(pc),a0
  131.     cmp.w    #cm_AddPW,d0
  132.     beq.s    .schluss
  133.     lea    RemovedTxt(pc),a0
  134.     cmp.w    #cm_RemovePW,d0
  135.     beq.s    .schluss
  136.     lea    RemAllTxt(pc),a0
  137.     bra.w    .schluss
  138. *-------
  139. .nopw:    lea    NoPWTxt(pc),a0
  140.     bra.w    .schluss
  141. *-------
  142. .nocrm:
  143.     lea    NoCrMTxt(pc),a0
  144.     bra.w    .schluss
  145. .printinfo:
  146.     lea    InfoTxt(pc),a0
  147.     bra.w    .schluss
  148. *------------
  149. ** Print some text to the CLI **
  150. PrintText:    ** a0:Text (0-terminated)
  151.     movem.l    d0-d3/a0-a1/a6,-(sp)
  152.     move.l    a0,d2
  153.     moveq    #-1,d3
  154. .count:    addq.l    #1,d3
  155.     tst.b    (a0)+
  156.     bne.s    .count
  157.     move.l    OutHandle(pc),d1
  158.     CALLDOS Write
  159.     movem.l    (sp)+,d0-d3/a0-a1/a6
  160.     rts
  161. *----------
  162. ** Skip spaces in the String at a0 (set a0 to the first char after the spaces)
  163. SkipSpaces:    ** a0:String (0-terminated)
  164.     tst.b    (a0)
  165.     beq.s    .End
  166.     cmp.b    #" ",(a0)+
  167.     beq.s    SkipSpaces
  168.     subq.l    #1,a0
  169. .End:    rts
  170. ***************************************
  171. _DOSBase:    dc.l    0
  172. _CrMBase:    dc.l    0
  173. OutHandle:    dc.l    0
  174. CLIParas:    dc.l    0,0
  175. ;PW:        dc.l    0
  176. DOSName:    dc.b    "dos.library",0
  177. CrMName:    CRMNAME
  178. NoCrMTxt:    dc.b    "Could not open CrM.library v4+",10,0
  179. InitTxt:    dc.b    27,"[33;1mCrMPW",27,"[0;33m V1.0",27,"[32m -- ",27,"[0m",0
  180. InfoTxt:    dc.b    "(c) 1993 Thomas Schwarz",10,10
  181.         dc.b    "Usage: CrMPW <command> <pw>",10,10
  182.         dc.b    "     <pw>: password to add/remove",10
  183.         dc.b    "<command>: a ·· Add PW to List",10
  184.         dc.b    "           r ·· Remove PW from List",10
  185.         dc.b    "       r all ·· Remove all PWs from List",10
  186.         dc.b    "  no command ·· Switch state",10,0
  187. AddedTxt:    dc.b    "added pw to list",10,0
  188. RemovedTxt:    dc.b    "removed pw from list",10,0
  189. RemAllTxt:    dc.b    "removed all pws from list",10,0
  190. NoAddTxt:    dc.b    "pw NOT added: already in list",10,0
  191. NoRemTxt:    dc.b    "pw NOT removed: not in list",10,0
  192. ;NoRemAllTxt:    dc.b    "nothing to remove!",10,0
  193. NoPWTxt:    dc.b    "NO pw given!",10,0
  194.